package com.tyut.musicdreamer.service.music.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tyut.musicdreamer.service.music.model.entity.UserFavoriteMusic;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户收藏音乐关系Mapper
 */
@Mapper
public interface UserFavoriteMusicMapper extends BaseMapper<UserFavoriteMusic> {

    /**
     * 检查用户是否收藏了指定音乐
     *
     * @param userId 用户ID
     * @param musicId 音乐ID
     * @return 是否收藏
     */
    @Select("SELECT COUNT(*) FROM md_user_favorite_music WHERE user_id = #{userId} AND music_id = #{musicId}")
    int checkFavorite(@Param("userId") Long userId, @Param("musicId") String musicId);

    /**
     * 获取用户收藏的所有音乐ID
     *
     * @param userId 用户ID
     * @return 音乐ID列表
     */
    @Select("SELECT music_id FROM md_user_favorite_music WHERE user_id = #{userId}")
    List<String> getUserFavoriteMusicIds(@Param("userId") Long userId);
} 